package simulation.listeners;

import dashboard.graph.AvgPickupGraph;
import events.packageEvents.PackagePickedUpEvent;
import framework.core.VirtualClock;
import framework.events.Event;
import framework.events.EventBroker;
import framework.events.EventListener;
import framework.utils.Utils;

public class PackagesPickedUpListener implements EventListener {

	private AvgPickupGraph graph;
	private double commands = 0;
	
	public PackagesPickedUpListener() {
		EventBroker.getEventBroker().register(this);
		graph = new AvgPickupGraph("Delivered Packages", "x", "Number of Packages", "");
	}
	
	@Override
	public void handleEvent(Event event) {
		if(event instanceof PackagePickedUpEvent  == true){
			graph.addValue(Utils.microsecondsToSeconds(VirtualClock.currentTime()), commands);
			commands++;
		}
	}

	@Override
	public void terminate() {
	}

}